﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace TfsTasksList
{
    public class WorkitemConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            WorkItemLinkCollection coll = value as WorkItemLinkCollection;
            if (coll == null)
                return "None";

            string retVal = "";

            if (coll.Count == 0)
                return "No links";

            foreach (Link l in coll)
            {
                if (retVal.Contains(l.Comment))
                    retVal +="Type: " + l.ArtifactLinkType.ToString() + "  ->" + l.Comment +  "\r";

            }
            return retVal;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}
